<admintpl file="header" />
<script type="text/javascript" src="public/js/My97DatePicker/WdatePicker.js?3"></script>
<script type="text/javascript" src="public/js/jquery.qrcode.min.js"></script>
</head>
<body>

<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li ><a href="{:U('AdminCard/import')}">卡导入</a></li>
        <li><a href="{:U('AdminCard/import_history')}" target="_self">导入历史</a></li>
        <li class="active"><a href="#" target="_self">已导入列表</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('AdminCard/card_list')}" onsubmit="return check_form();">
        ICCID:
        <input type="text" name="s_number" style="width: 200px;"  value="{$s_number}">
        接入号:
        <input type="text" name="s_card_number" style="width: 200px;"  value="{$s_card_number}">
        <input type="submit" class="btn btn-primary" value="搜索" />
    </form>
    <form class="js-ajax-form" action="" method="post">

        <table class="table table-hover table-bordered table-list">

                <thead>
                <tr>
                    <td>ICCID</td>
                    <td>接入号码</td>
                    <td>二维码</td>
                </tr>
                </thead>
                <foreach name="list" item="vo">
                    <tr>
                        <td>{$vo.card_iccid}</td>
                        <td>{$vo.card_number}</td>
                        <td>
                            <!--<a href="javascript:open_img('{$vo.card_iccid}')">查看</a>-->
                            <img id="i{$vo.card_iccid}" width="150" height="150"/>
                            <a class="a2{$vo.card_iccid}" download="{$vo.card_iccid}.png">下载</a>
                            <div id="d{$vo.card_iccid}"></div>
                            <script>
                                $(function(){
                                    var str = "https://www.<php> echo $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];</php>?g=Wulian&m=Index&a=index&card_iccid={$vo.card_iccid}";
                                    console.log(str);
                                    var qrcode = $('#d{$vo.card_iccid}').qrcode(str).hide();
                                    var canvas=qrcode.find('canvas').get(0);
                                    var canvas_img = canvas.toDataURL('image/jpg');
                                    $('#i{$vo.card_iccid}').attr('src',canvas_img);
                                    $('.a2{$vo.card_iccid}').attr('href',canvas_img);
                                });
                            </script>
                        </td>
                    </tr>
                </foreach>

        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script>
//    function open_img(card_iccid){
//        var img_str = $("#i"+card_iccid).attr("src");
//       // var url = img_str.replace(/^data:image\/[^;]+/, 'data:application/octet-stream');
//        location.href=img_str;
//
//    }
    function start_time(){
        WdatePicker({maxDate:"{$a}",onpicking:function(dp){
            $("#h_start_time").val(dp.cal.getNewDateStr());
        }
    });
    }
    function end_time(){
        WdatePicker({minDate:"{$b}",onpicking:function(dp){
            $("#h_end_time").val(dp.cal.getNewDateStr());
        }
        });
    }

    function check_form(){
        var h_start_time = $("#h_start_time").val();
        var h_end_time = $("#h_end_time").val();
        console.log(h_start_time);
        var start_arr = h_start_time.split("-");
        var end_arr = h_end_time.split("-");
        if(start_arr[0] == end_arr[0] && start_arr[1] == end_arr[1]){
            return true;
        }else{
            alert("查询日期必须在同一个月!");return false;
        }
    }


    $(function(){
       $("#s_show").change(function(){
           var s_show = $(this).val();
           if(s_show == 2){
               $(".s_number").show();
               $(".s_number").css("display","inline-block");
           }else{
               $(".s_number").hide();
           }
       });
    });




</script>
<script src="__PUBLIC__/js/common.js"></script>


</body>
</html>